/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  height: 100vh;
  overflow: hidden;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  color: #ffffff;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* 主容器 */
#app {
  display: flex !important;
  flex-direction: column;
  height: 100vh;
  backdrop-filter: blur(10px);
}

/* 内容区域 */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 20px 20px 0 0;
  margin: 8px 8px 0 8px;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-content {
  height: 100%;
  overflow: hidden;
}

/* 区域头部 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(76, 175, 80, 0.2);
  border-radius: 20px;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4CAF50;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.2);
  }
}

.status-text {
  font-size: 12px;
  color: #4CAF50;
  font-weight: 500;
}

/* 流程列表 */
.flow-list {
  padding: 20px;
  height: calc(100% - 80px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.flow-item {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.flow-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.flow-item:hover::before {
  left: 100%;
}

.flow-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 123, 255, 0.3);
  border-color: rgba(0, 123, 255, 0.5);
}

.flow-item.selected {
  background: linear-gradient(135deg, rgba(16, 92, 251, 0.3) 0%, rgba(16, 92, 251, 0.2) 100%) !important;
  border-color: #105CFB !important;
  box-shadow: 0 8px 32px rgba(16, 92, 251, 0.4) !important;
  transform: translateY(-2px);
}

.flow-item.selected .flow-name {
  color: white !important;
  font-weight: 600;
}

.flow-icon {
  font-size: 36px;
  margin-right: 20px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(0, 123, 255, 0.5));
}

.flow-info {
  flex: 1;
}

.flow-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.flow-desc {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

/* 聊天界面 */
#chat-tab {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 计算高度：从chat-header底部到chat-input-container顶部 */
  height: calc(100vh - 140px - 120px - 85px); /* 减去header高度、input区域高度、底部导航高度 */
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  max-height: 100%;
}

.message {
  margin-bottom: 16px;
  max-width: 75%;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.sent {
  margin-left: auto;
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border-radius: 20px 20px 6px 20px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.message.received {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
  color: #ffffff;
  border-radius: 20px 20px 20px 6px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.message-content {
  font-size: 16px;
  line-height: 1.5;
  word-break: break-word;
}

.message-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 6px;
  text-align: right;
}

/* 聊天输入区域 */
.chat-input-container {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  padding: 16px;
}

.chat-input-area {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.quick-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  transform: translateY(-1px);
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.chat-input {
  width: 100%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 25px;
  padding: 14px 22px 14px 22px;
  font-size: 16px;
  outline: none;
  transition: all 0.3s ease;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  font-family: inherit;
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.chat-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(0, 123, 255, 0.6);
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

.input-counter {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  font-weight: 500;
}

.send-btn {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  /* min-width: 80px; */
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 122, 255, 0.4);
}

.send-btn:active {
  transform: translateY(0) scale(0.95);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 底部Tab栏 */
.bottom-tab {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  padding: 12px 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  height: 85px;
  backdrop-filter: blur(20px);
  margin: 0 8px 8px 8px;
  border-radius: 0 0 20px 20px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 10px 24px;
  border-radius: 16px;
  position: relative;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
}

.tab-item[aria-selected="true"] {
  opacity: 1;
  background: rgba(0, 123, 255, 0.2);
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

.tab-item:active {
  transform: scale(0.95);
}

.tab-indicator {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #007AFF, #0056CC);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.tab-item[aria-selected="true"] .tab-indicator {
  width: 60%;
}

.tab-icon {
  font-size: 26px;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

.tab-text {
  font-size: 12px;
  color: #ffffff;
  font-weight: 500;
}

/* 圆形麦克风按钮 */
.mic-button {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #FF3B30 0%, #FF2D55 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(255, 59, 48, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-family: inherit;
  color: inherit;
}

.mic-wave {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  opacity: 0;
  animation: wave-pulse 2s infinite;
}

@keyframes wave-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.mic-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translate(-50%, -50%);
}

.mic-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(255, 59, 48, 0.5);
}

.mic-button:active::before,
.mic-button.recording::before {
  width: 100%;
  height: 100%;
}

.mic-button:active,
.mic-button.recording {
  transform: scale(0.9);
  background: linear-gradient(135deg, #FF2D55 0%, #FF1744 100%);
  box-shadow: 0 4px 20px rgba(255, 59, 48, 0.6);
}

.mic-icon {
  font-size: 32px;
  color: white;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.mic-button.recording .mic-icon {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
  }
  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
  }
}

/* 聊天头部 */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
}

.chat-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-status {
  display: flex;
  align-items: center;
}

.typing-indicator {
  font-size: 12px;
  color: rgba(0, 123, 255, 0.8);
  font-weight: 500;
  animation: typing-pulse 1.5s infinite;
}

@keyframes typing-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.clear-btn {
  background: linear-gradient(135deg, #ff4444 0%, #cc3333 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(255, 68, 68, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.clear-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 68, 68, 0.4);
}

.clear-btn:active {
  transform: translateY(0) scale(0.95);
}

.btn-icon {
  font-size: 14px;
}

.btn-text {
  font-size: 13px;
  font-weight: 500;
}

/* 思考消息样式 */
.message.think {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 123, 255, 0.08) 100%);
  border: 1px solid rgba(0, 123, 255, 0.3);
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 123, 255, 0.2);
}

.think-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.think-label {
  font-size: 12px;
  color: rgba(0, 123, 255, 0.8);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.think-text {
  font-size: 14px;
  color: #ffffff;
  line-height: 1.5;
  background: rgba(0, 123, 255, 0.1);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 123, 255, 0.2);
}

/* 消息元信息 */
.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.6;
}

.message-from {
  font-weight: 600;
  color: rgba(0, 123, 255, 0.8);
}

.message-time {
  color: rgba(255, 255, 255, 0.6);
}

/* 系统消息样式 */
.message.system {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  color: rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  padding: 12px 16px;
  margin: 12px auto;
  text-align: center;
  font-size: 14px;
  max-width: 80%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

/* 来源样式 */
.message.from-agent {
  border-left: 3px solid #4CAF50;
  box-shadow: -3px 0 10px rgba(76, 175, 80, 0.3);
}

.message.from-controller {
  border-left: 3px solid #2196F3;
  box-shadow: -3px 0 10px rgba(33, 150, 243, 0.3);
}

/* 连接状态 */
.connecting {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.connecting-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(15, 15, 35, 0.95) 0%, rgba(26, 26, 46, 0.95) 100%);
  backdrop-filter: blur(20px);
}

.connecting-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 1;
  position: relative;
}

.connecting-text {
  margin-top: 20px;
}

.connecting-text h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #ffffff;
}

.connecting-text p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.connecting-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid #007AFF;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 30px rgba(0, 123, 255, 0.4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 错误状态 */
.error {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 68, 68, 0.95) 0%, rgba(204, 51, 51, 0.95) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  text-align: center;
  padding: 20px;
  z-index: 1000;
  backdrop-filter: blur(20px);
}

/* 响应式调整 */
@media (max-width: 375px) {
  .flow-item {
    padding: 16px;
  }
  
  .flow-icon {
    font-size: 32px;
    margin-right: 16px;
  }
  
  .chat-input-area {
    padding: 16px;
  }
  
  .bottom-tab {
    height: 75px;
  }
  
  .mic-button {
    width: 60px;
    height: 60px;
  }
  
  .mic-icon {
    font-size: 28px;
  }
}

/* 隐藏元素 */
.hidden {
  display: none !important;
}

/* 加载动画 */
.loading {
  opacity: 0.6;
  pointer-events: none;
  filter: blur(1px);
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 发光效果 */
.glow {
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.5);
  }
  to {
    box-shadow: 0 0 30px rgba(0, 123, 255, 0.8);
  }
}